package com.mtnz.njk.Controller;

import com.mtnz.njk.Service.OrderManagerService;
import com.mtnz.njk.result.ResponseMessage;
import com.mtnz.njk.result.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;

/**
 * @Description: 订单管理控制层
 * @Author: FBL
 * @CreateDate: 2019\8\21 0021 8:57
 * @Version: 1.0
 */
@RestController
@RequestMapping("/order")
@CrossOrigin
public class OrderManagerController {

    @Autowired
    OrderManagerService orderManagerService;

    /**
     * 订单信息列表
     *
     * @param key
     * @param pageNum
     * @param pageSize
     * @return
     * @throws Exception
     */
    @PostMapping("/listOrderInfo")
    public ResponseResult listOrderInfo(String customerId,String serviceId,String orderStatus,String payMethod, String key, String beginTime, String endTime, Integer dealStatus, String orderInfoId, @RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "10") Integer pageSize) throws Exception {
        return orderManagerService.listOrderInfo(customerId,serviceId,orderStatus,payMethod, key, beginTime, endTime, dealStatus, orderInfoId, pageNum, pageSize);
    }

    /**
     * 修改订单备注以及修改订单状态
     *
     * @param orderInfoId
     * @param orderExplain
     * @return
     * @throws Exception
     */
    @PostMapping("/updateOrderExplain")
    public ResponseResult updateOrderRemark(String orderInfoId,String orderExplain,String orderStatus) throws Exception {
        if( orderInfoId == null || ("").equals(orderInfoId))
            return new ResponseResult(ResponseMessage.NULL_REQUEST);
        return orderManagerService.updateOrderRemark(orderInfoId,orderExplain,orderStatus);
    }

    /**
     * 订单Excel导出
     *
     * @return
     * @throws Exception
     */
    @GetMapping("/orderExcel")
    public ResponseResult orderExcel(HttpServletResponse response,String beginTime,String endTime) throws Exception {
        return orderManagerService.orderExcel(response,beginTime,endTime);
    }

}
